package jobflow.entity;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.validator.Pattern;

@Entity(name = "Departman")
@Table(name = "DEPARTMAN")
public class Departman implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Long id;
	private String departmanAdi;
	private String departmanSorumlusu;
	private String dahiliTel;
	private Long aktif;
	private byte[] data;
	private String image;
     
	private boolean visible=Boolean.FALSE;

	@Id
	@GeneratedValue
	@Column(name = "ID")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "DEPARTMAN_ADI")
	public String getDepartmanAdi() {
		return departmanAdi;
	}

	public void setDepartmanAdi(String departmanAdi) {
		this.departmanAdi = departmanAdi;
	}

	@Column(name = "DEPARTMAN_SORUMLUSU")
	public String getDepartmanSorumlusu() {
		return departmanSorumlusu;
	}

	public void setDepartmanSorumlusu(String departmanSorumlusu) {
		this.departmanSorumlusu = departmanSorumlusu;
	}

	@Column(name = "DAHILI_TEL")
	@Pattern(regex = "^\\d*$", message = "Gecersiz Karakter")
	public String getDahiliTel() {
		return dahiliTel;
	}

	public void setDahiliTel(String dahiliTel) {
		this.dahiliTel = dahiliTel;
	}

	public void setAktif(Long aktif) {
		this.aktif = aktif;
	}

	@Column(name = "AKTIF", scale = 1)
	public Long getAktif() {
		return aktif;
	}

	public void setData(byte[] data) {
		this.data = data;
	}

	
	@Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "RESIM",length=100000)
	public byte[] getData() {
		return data;
	}

	@PrePersist
	@Transient
	public void prePersist() {
		if (getAktif() == null) {
			setAktif(1L);
		}
	}

	public void setImage(String image) {
		this.image = image;
	}
    @Transient
	public String getImage() {
		return image;
	}

	public void setVisible(boolean visible) {
		this.visible = visible;
	}
    @Transient
	public boolean isVisible() {
		return visible;
	}

	



}
